package com.wyq.new_springboot.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wyq.new_springboot.entity.TUser;
import com.wyq.new_springboot.mapper.TUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr Wei
 * @since 2021-03-24
 */
@Controller
@RequestMapping("/tUser")
public class TUserController {
    @Autowired
    TUserMapper tUserMapper;

    @RequestMapping("/test1")
    @ResponseBody
    public String test1(){
        //根据id查询
        TUser tUser = tUserMapper.selectById(1L);
        System.out.println("根据id查询");
        System.out.println(tUser);
        //组合查询
        Map map =new HashMap<>();
        map.put("user_password","123");
        tUserMapper.selectByMap(map).forEach(System.out::println);
        return "hello world";
    }
    @RequestMapping("/test2")
    @ResponseBody
    public String test2(){
        QueryWrapper<TUser> wrapper=new QueryWrapper<>();
        wrapper.eq("user_name","lisi");
        tUserMapper.selectList(wrapper).forEach(System.out::println);
        return "hello world!";
    }
}

